package com.jprocms.module.cms.dal.dataobject.content;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @TableName cms_content_tag
 */
@NoArgsConstructor
@AllArgsConstructor
@KeySequence("cms_content_tag") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@TableName(value = "cms_content_tag")
public class ContentTagDo implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 内容ID
     */
    private Long contentId;

    /**
     * tag_id
     */
    private Long tagId;

    @JsonIgnore
    private ContentDO content = new ContentDO();
    @JsonIgnore
    private TagDO tag = new TagDO();

    public ContentTagDo(Long contentId, Long tagId) {
        this.contentId = contentId;
        this.tagId = tagId;
    }

    /**
     * 内容ID
     */
    public Long getContentId() {
        return contentId;
    }

    /**
     * 内容ID
     */
    public void setContentId(Long contentId) {
        this.contentId = contentId;
    }

    /**
     * tag_id
     */
    public Long getTagId() {
        return tagId;
    }

    /**
     * tag_id
     */
    public void setTagId(Long tagId) {
        this.tagId = tagId;
    }

    public ContentDO getContent() {
        return content;
    }

    public void setContent(ContentDO content) {
        this.content = content;
    }

    public TagDO getTag() {
        return tag;
    }

    public void setTag(TagDO tag) {
        this.tag = tag;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ContentTagDo other = (ContentTagDo) that;
        return (this.getContentId() == null ? other.getContentId() == null : this.getContentId().equals(other.getContentId()))
                && (this.getTagId() == null ? other.getTagId() == null : this.getTagId().equals(other.getTagId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getContentId() == null) ? 0 : getContentId().hashCode());
        result = prime * result + ((getTagId() == null) ? 0 : getTagId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", contentId=").append(contentId);
        sb.append(", tagId=").append(tagId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}